home *** CD-ROM | disk | FTP | other *** search
- /* wireframe.c */
-
- /* wireframe package : written by : Jason R. Wilson */
- /* last revised : Feb. 21, 1993 */
-
- /* provides wireframe support using postscript operators */
-
- #include <math.h>
- #include <stdio.h>
- #import <dpsclient/wraps.h>
- #import <appkit/graphics.h>
- #include "datastruct.h"
- #include "clip.h"
-
- Window ViewWindow;
- int winWidth;
- int winHeight;
-
- void InitWire (Window viewwindow,int winwidth,int winheight)
- /* set-up to use wireframe package */
- {
- ViewWindow = viewwindow;
- winWidth = winwidth;
- winHeight = winheight;
- }
-
- void DrawWire(ObjectCell *ObjectHead)
- /* when counts gets up over 2000 a stroke and flush are done to keep the
- buffer postscript buffer from overflowing: JRW, 2-2-93 */
- /* draws only patches (not elements */
-
- {
- ObjectCell *Object;
- PolygonCell *CurrentPoly;
- VisVertexCell *CurrentVert;
- Homog FirstPoint;
- Boolean Gone;
- double distancex,distancey;
- int count;
-
- distancex = ViewWindow.Wr - ViewWindow.Wl;
- distancey = ViewWindow.Wt - ViewWindow.Wb;
- count = 0;
-
- Object = ObjectHead;
-
- while (!(Object == NULL))
- {
- CurrentPoly = Object->PolygonHead;
- while (!(CurrentPoly == NULL))
- {
- Gone = false;
- ClipPolygon (CurrentPoly,ViewWindow,&Gone);
- if (Gone == false)
- {
- CurrentVert = CurrentPoly->VisVertices;
- FirstPoint = CurrentVert->ViewPosition;
- PSmoveto(rint((FirstPoint.hom[0]-ViewWindow.Wl)/(distancex)*winWidth),
- rint((FirstPoint.hom[1]-ViewWindow.Wb)/(distancey)*winHeight));
- count++;
- while (!(CurrentVert->Next == NULL))
- {
- CurrentVert = CurrentVert->Next;
- PSlineto(rint((CurrentVert->ViewPosition.hom[0]-ViewWindow.Wl)/(distancex)*winWidth),
- rint((CurrentVert->ViewPosition.hom[1]-ViewWindow.Wb)/(distancey)*winHeight));
- count++;
- }
-
- PSlineto(rint((FirstPoint.hom[0]-ViewWindow.Wl)/(distancex)*winWidth),
- rint((FirstPoint.hom[1]-ViewWindow.Wb)/(distancey)*winHeight));
- count++;
- }
- CurrentPoly = CurrentPoly->Next;
- if (count > 2000)
- {
- count = 0;
- PSsetgray(NX_BLACK);
- PSstroke();
- PSflushgraphics();
- }
- }
- Object = Object->Next;
- }
- }
-
- /*----------------------------------------------------------------------*/
-
- void drawwire(int *count,PolygonCell *CurrentPoly)
- /* when counts gets up over 1000 a stroke and flush are done to keep the
- buffer postscript buffer from overflowing: JRW, 2-2-93 */
- {
- VisVertexCell *CurrentVert;
- Homog FirstPoint;
- Boolean Gone;
- double distancex,distancey;
-
- distancex = ViewWindow.Wr - ViewWindow.Wl;
- distancey = ViewWindow.Wt - ViewWindow.Wb;
-
- if (CurrentPoly->Subs[0] == NULL)
- {
- Gone = false;
- ClipPolygon (CurrentPoly,ViewWindow,&Gone);
- if (Gone == false)
- {
- CurrentVert = CurrentPoly->VisVertices;
- FirstPoint = CurrentVert->ViewPosition;
- PSmoveto(rint((FirstPoint.hom[0]-ViewWindow.Wl)/(distancex)*winWidth),
- rint((FirstPoint.hom[1]-ViewWindow.Wb)/(distancey)*winHeight));
- (*count)++;
- while (!(CurrentVert->Next == NULL))
- {
- CurrentVert = CurrentVert->Next;
- PSlineto(rint((CurrentVert->ViewPosition.hom[0]-ViewWindow.Wl)/(distancex)*winWidth),
- rint((CurrentVert->ViewPosition.hom[1]-ViewWindow.Wb)/(distancey)*winHeight));
- (*count)++;
- }
-
- PSlineto(rint((FirstPoint.hom[0]-ViewWindow.Wl)/(distancex)*winWidth),
- rint((FirstPoint.hom[1]-ViewWindow.Wb)/(distancey)*winHeight));
- (*count)++;
- if ((*count) > 2000)
- {
- (*count) = 0;
- PSsetgray(NX_BLACK);
- PSstroke();
- PSflushgraphics();
- }
- }
- }
- else
- {
- drawwire (count,CurrentPoly->Subs[0]);
- drawwire (count,CurrentPoly->Subs[1]);
- drawwire (count,CurrentPoly->Subs[2]);
- drawwire (count,CurrentPoly->Subs[3]);
- }
- }
-
-
- /***********************************************************************/
-
- void DrawWireFull (ObjectCell *ObjectHead)
- {
- ObjectCell *Object;
- PolygonCell *CurrentPoly;
- int count;
-
- Object = ObjectHead;
- count = 0;
-
- while (!(Object == NULL))
- {
- CurrentPoly = Object->PolygonHead;
- while (!(CurrentPoly == NULL))
- {
- drawwire (&count,CurrentPoly);
- CurrentPoly = CurrentPoly->Next;
- }
- Object = Object->Next;
- }
- }
-
-
-
-